package com.wgts.wgts.mvp.view.activity.shopkeeper;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.wgts.wgts.R;
import com.wgts.wgts.base.BaseActivity;
import com.wgts.wgts.localbean.LocalMoneyRecordProgress;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 提现进度
 */
public class PutForwardProgressActivity extends BaseActivity {


    public static final String PROGRESS = "PROGRESS";
    @BindView(R.id.img_back)
    ImageView imgBack;
    @BindView(R.id.img_submission)
    ImageView imgSubmission;
    @BindView(R.id.tv_submission)
    TextView tvSubmission;
    @BindView(R.id.tv_submission_detail)
    TextView tvSubmissionDetail;
    @BindView(R.id.tv_submission_date)
    TextView tvSubmissionDate;
    @BindView(R.id.line1)
    View line1;
    @BindView(R.id.img_examine_result)
    ImageView imgExamineResult;
    @BindView(R.id.tv_submission_result)
    TextView tvSubmissionResult;
    @BindView(R.id.tv_submission_result_detail)
    TextView tvSubmissionResultDetail;
    @BindView(R.id.tv_submission_result_date)
    TextView tvSubmissionResultDate;

    private ArrayList<LocalMoneyRecordProgress> progress;

    @Override
    public void init() {
        progress = getIntent().getParcelableArrayListExtra(PROGRESS);
    }

    public void onCreate(Bundle saveInstance) {
        super.onCreate(saveInstance);
        setContentView(R.layout.put_forward_progress_activity);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        if (progress != null && progress.size() == 2) {
            if (progress.get(1).state.equals("0")) {
                imgExamineResult.setImageResource(R.mipmap.putaward);
                tvSubmission.setText("提现申请提交成功");
                tvSubmissionResult.setText("提现申请审核中");
            } else if (progress.get(1).state.equals("2")) {
                imgExamineResult.setImageResource(R.mipmap.put_award_error);
                tvSubmission.setText("提现申请提交成功");
                tvSubmissionResult.setText("提现申请审核失败");
            } else {
                imgExamineResult.setImageResource(R.mipmap.put_award_success);
                tvSubmission.setText("提现申请提交成功");
                tvSubmissionResult.setText("提现申请审核成功");
            }
            tvSubmissionDate.setText(progress.get(0).stateTime);
            tvSubmissionDetail.setText(progress.get(0).msg);
            tvSubmissionResultDate.setText(progress.get(1).stateTime);
            tvSubmissionResultDetail.setText(progress.get(1).msg);

        } else {

            Date currentTime = new Date();
            SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            String dateString = formatter.format(currentTime);

            tvSubmissionDate.setText(dateString);
            imgExamineResult.setImageResource(R.mipmap.putaward);
            tvSubmission.setText("审核中");
            tvSubmissionResultDate.setText("");
            tvSubmissionResultDetail.setText("");
        }

    }

    @OnClick(R.id.img_back)
    public void onViewClicked() {
        finish();
    }
}
